import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import BasicPage from '../page/basic-page'
import Product from "@/views/Product";
import ProductList from "@/views/product-list";
import contact from "@/views/contact";

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err)
}

const routes = [
    {
        path: '/',
        name: 'Home',
        component: BasicPage,
        redirect: '/index',
        children: [
            {
                path: '/index',
                name: '首页',
                component: Home
            },
            {
                path: '/product',
                name: '产品',
                component: Product,
            },
            {
                path: '/product-list',
                name: '产品',
                component: ProductList,
            },
            {
                path: '/contact',
                name: '联系我们',
                component: contact,
            }
        ]
    },
    {
        path: '/about',
        name: 'About',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
    }
]

const router = new VueRouter({
    routes
})

export default router
